/*
 * This file is part of the Sx Framework Library.
 * 
 * Copyright (C) 2013 University of Colorado Denver
 * <min.choi@ucdenver.edu> <shane.transue@ucdenver.edu>
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy 
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
 * copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in 
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
 * DEALINGS IN THE SOFTWARE.
 */
#ifndef SX_VEGA_EULER_INTEGRATOR_H
#define SX_VEGA_EULER_INTEGRATOR_H

#include <sxVega_Integrator.h>

/* VegaFEM Includes */
#include <integratorBase.h>

class SparseMatrix;
class ForceModel;

namespace Sx {
namespace Vega {
namespace Physics {

class Vega_EulerIntegrator : public Vega_Integrator {
public:
	Vega_EulerIntegrator(unsigned int nodeCount, SparseMatrix* massMatrix, ForceModel* forceModel);
	virtual ~Vega_EulerIntegrator();

	bool addNodeExternalForce(unsigned int index, const Eigen::Vector3d& force);
	bool addNodeVelocity(unsigned int index, const Eigen::Vector3d& velocity);
	bool addNodePosition(unsigned int index, const Eigen::Vector3d& position);

	bool setNodeExternalForce(unsigned int index, const Eigen::Vector3d& force);
	bool setNodeExternalForce(unsigned int index, double x, double y, double z);
	bool setNodeInternalForce(unsigned int index, const Eigen::Vector3d& force);
	bool setNodeInternalForce(unsigned int index, double x, double y, double z);
	bool setNodeVelocity(unsigned int index, const Eigen::Vector3d& velocity);
	bool setNodeVelocity(unsigned int index, double x, double y, double z);
	bool setNodePosition(unsigned int index, const Eigen::Vector3d& position);
	bool setNodePosition(unsigned int index, double x, double y, double z);
	bool setNodeAcceleration(unsigned int index, const Eigen::Vector3d& acceleration);
	bool setNodeAcceleration(unsigned int index, double x, double y, double z);
	
	Eigen::Vector3d getNodeInternalForce(unsigned int index);
	Eigen::Vector3d getNodeExternalForce(unsigned int index);
	Eigen::Vector3d getNodeAcceleration(unsigned int index);
	Eigen::Vector3d getNodeVelocity(unsigned int index);
	Eigen::Vector3d getNodePosition(unsigned int index);
	
	void performTimestep(double dt);
	void reset();
	void zeroExternalForces();

	bool isSymplectic() const;

protected:
	/* POINTER_OWNERSHIP: YES */
	IntegratorBase* integrator;
};

}

}

}

#endif
